package com.example.service.impl;

import com.example.mapper.CategoryMapper;

import com.example.pojo.Category;
import com.example.service.CategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CategoryServiceImpl implements CategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    //查询分类
    public Category getUserByName(Category category){

        return categoryMapper.getCategoryByName(category.getCategory_name());
    }

    @Override
    public Category getCategoryById(int id) {
        return categoryMapper.getCategoryById(id);
    }

    @Override
    public Category getCategoryByName(Category category) {
        return categoryMapper.getCategoryByName(category.getCategory_name());
    }

    @Override
    public int addCategory(Category category) {return categoryMapper.addCategory(category);}


    public List<Category> getAllCategory() {
        return categoryMapper.getAllCategoryMap();
    }


    @Override
    public int updateCategory(Category category) {
        return categoryMapper.updateCategory(category);
    }

    @Override
    public void deleteCategoryById(int category_id) {categoryMapper.deleteById(category_id);}


}
